$(function () {
    $('.allcat').hover(function () {
        console.log(1111)
        $('.blist').css({ 'display': 'block' })

    }, function () {

        $('.blist').css({ 'display': 'none' })
    })
    $('.menus').hover(function () {
        $('.uli').css({ 'display': 'block' })
    }, function () {
        $('.uli').css({ 'display': 'none' })
    })
    $('.menus1').hover(function () {
        $('.uli1').css({ 'display': 'block' })
    }, function () {
        $('.uli1').css({ 'display': 'none' })
    })

    // 退出按钮事件
    $('.tc').click(function () {
        localStorage.removeItem('token')
        localStorage.removeItem('username')
        location.href = 'login.html'
    })
    $('#yh').html(username)
    // 退出按钮事件
})














let token = localStorage.getItem('token')
console.log(token)
let username = localStorage.getItem('username')
// let oncli = document.querySelector('.on-cli')
// let areg = document.querySelector('.a-reg')
// let yonghu = document.querySelector('#yonghu')
// let btn = document.querySelector('.btn')
//如果已经登录 第一个div 显示
if (token) {
    $('.reg').hide()
    $('.login').hide()
    $('.use').show()
    // oncli.style.display = 'none'
    // areg.style.display = 'none'
    // yonghu.style.display = 'block'
    // btn.style.display='block'

} else {
    // oncli.style.display = 'block'
    // areg.style.display = 'block'
    // yonghu.style.display = 'none'
    // btn.style.display='none'
    $('.reg').show()
    $('.login').show()
    $('.use').hide()
}



$.get('http://47.104.244.134:8080/goodsbytid.do', {
    tid: '13', page: '1', limit: '8'
}).done(data => {
    if (data.code == 200) {
        console.log(data)
        let html = ''
        let text=''
        data.data.forEach(p => {
            console.log(p)
            console.log(data.id)
            html += `
        
                 <a href="item.html?pid=${p.id}" 
                style="display:flex;flex-direction: column;align-items: center;width:240px;height:330px;
                margin:10px 10px;background:#f5f5f5">
                <img src="${p.picurl}" alt="零食" style="width:240px;height:240px">
                <span class="name" title="好吃的零食">${p.name}</span>
                 <span class="desc" title="真是美味">${p.info}</span>
                <span class="price">
                    <span class="currPrice" style="color:red">¥${p.price}</span>
                </span>
        
        
                </a>
        
            `

        });

        $('.list').html(html)
        var img = document.querySelector('img')
        var sc = img.src
        console.log(sc)
        if (sc == 'http://rr.knet.cn/static/images/logo/cnnic.png') {
            console.log(111)
            sc = 'http://img12.360buyimg.com/n7/s230x230_jfs/t19513/186/1027434391/438862/1b6bfdbd/5ab5a467N8857d921.jpg!cc_230x230.jpg'
            console.log(sc)
        }
    }
})

// let pagenum = 0
// let obj = {}
// if (token) {
//     obj.uid = token
// }

// loadData()

// function loadData() {
//     axios.get(proListApi, {
//         params: obj
//     }).then(res => {
//         console.log(res)
//         let html = ''
//         res.data.data.forEach(p => {
//             html += `

//          <a href="item.html?pid=${p.pid}" 
//         style="display:flex;flex-direction: column;align-items: center;width:240px;height:330px;
//         margin:10px 10px;background:#f5f5f5">
//         <img src="${p.pimg}" alt="糖猫M2" style="width:240px;height:240px">
//         <span class="name" title="糖猫M2">${p.pname}</span>
//         <span class="desc" title="4G视频通话，3秒极速定位">${p.pdesc}</span>
//         <span class="price">
//             <span class="currPrice" style="color:red">¥${p.pprice}</span>
//         </span>


//         </a>

//     `

//         });
//         let list = document.querySelector('.list')
//         list.innerHTML = html;


//     })
// }